package com.yan.demo;

public class Demo4 {
    public static void main(String[] args) {
        StringBuffer stringBuffer = new StringBuffer();
        // 添加
        stringBuffer.append(77777);
        System.out.println("stringBuffer = " + stringBuffer);
        // 截取
        String substring = stringBuffer.substring(1);
        System.out.println("substring = " + substring);
        // 删除
        stringBuffer.delete(1,3);
        System.out.println("stringBuffer = " + stringBuffer);
        // 索引
        int index = stringBuffer.indexOf("7");
        System.out.println("index = " + index);
        // 替换
        stringBuffer.replace(2 ,4 , "a");
        System.out.println("stringBuffer = " + stringBuffer);
        // 反转
        stringBuffer.reverse();
        System.out.println("stringBuffer = " + stringBuffer);
        // 设置长度
        stringBuffer.setLength(1);
        System.out.println("stringBuffer = " + stringBuffer);

    }
}
